package com.schoolai.schoolset.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.schoolai.entity.SchoolSetSmsLog;
import com.schoolai.schoolset.mapper.SchoolSetSmsLogMapper;
import com.schoolai.schoolset.req.SmsLogREQ;
import com.schoolai.schoolset.service.ISchoolSetSmsLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schoolai.util.base.Result;
import io.micrometer.common.util.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author bobby
 * @since 2025-11-14
 */
@Service
public class SchoolSetSmsLogServiceImpl extends ServiceImpl<SchoolSetSmsLogMapper, SchoolSetSmsLog> implements ISchoolSetSmsLogService {

    @Override
    public Result queryPage(SmsLogREQ req) {
        LambdaQueryWrapper<SchoolSetSmsLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(req.getPhone())){
            lambdaQueryWrapper.like(SchoolSetSmsLog::getPhone, req.getPhone());

        }
        lambdaQueryWrapper.orderByDesc(SchoolSetSmsLog::getCreatedTime);
        return Result.ok(baseMapper.selectPage(req.getPage(), lambdaQueryWrapper));
    }
}
